﻿using System.Collections.Generic;

namespace Application.Interfaces.Mapping
{
    public static class MappingExtensions
    {
        public static TDestination To<TSource, TDestination>(this TSource source)
        {
            var mapper = AppEngine.Container.GetInstance<IMapper>();
            return mapper.To<TSource, TDestination>(source);
        }

        public static IEnumerable<TDestination> To<TSource, TDestination>(this IEnumerable<TSource> source)
        {
            var mapper = AppEngine.Container.GetInstance<IMapper>();
            return mapper.To<IEnumerable<TSource>, IEnumerable<TDestination>>(source);
        }

        public static void From(this object entity, params object[] source)
        {
            var mapper = AppEngine.Container.GetInstance<IMapper>();
            mapper.From(entity, source);
        }

        public static void FromSkipNull(this object entity, params object[] source)
        {
            var mapper = AppEngine.Container.GetInstance<IMapper>();
            mapper.FromSkipNull(entity, source);
        }
    }
}